﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Data.SqlClient;
using System.Drawing;
using System.Net.Mail;

using System.Web.Services;

using System.IO.MemoryMappedFiles;

public partial class realia_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        SqlConnection conn = null;
        conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        conn.Open();
        //  string st = null;
        //  SqlCommand da = new SqlCommand("select * from yoga", conn);
        //  SqlDataReader d = da.ExecuteReader();
        //  while (d.Read())
        //  {
        //      st = d.GetValue(6).ToString();

        //  }
        //d.Close();
        //  if (st == "1")
        //  {

        SqlCommand cmd = new SqlCommand("select * from properties where p_id = (SELECT MAX(p_id) FROM properties)", conn);
        SqlDataReader dr = cmd.ExecuteReader();
        if (dr.Read())
        {
          
            Label1.Text = dr[21].ToString();
            Label2.Text = dr[15].ToString();
            Label3.Text = dr[1].ToString();
            //Label4.Text = dr[9].ToString();
            // Label5.Text = dr[50].ToString();
            // Labelarea.Text = dr[49].ToString();
            Label6.Text = dr[57].ToString();
            Label61.Text = dr[37].ToString();
           
            Label38.Text = dr[10].ToString();
            Label37.Text = dr[15].ToString();
            Label39.Text = dr[21].ToString();


            Label49.Text = dr[21].ToString();
            Label50.Text = dr[15].ToString();
            Label51.Text = dr[1].ToString();
            Label52.Text = dr[9].ToString();
            Label53.Text = dr[57].ToString();
            Label54.Text = dr[37].ToString();
           

            dr.Close(); conn.Close();
        }
        //conn.Close();
       
        SqlConnection conn1 = null;
        conn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        conn1.Open();
        SqlCommand cmd1 = new SqlCommand("select * from properties where p_id=(SELECT MIN(p_id) FROM properties)", conn1);
        SqlDataReader dr1 = cmd1.ExecuteReader();
        if (dr1.Read())
        {

           Label7.Text = dr1[21].ToString();
            Label8.Text = dr1[15].ToString();
            Label9.Text = dr1[1].ToString();
       //     Label10.Text = dr1[9].ToString();
       //     Label11.Text = dr1[50].ToString();
            Label12.Text = dr1[57].ToString();
            Label62.Text = dr1[37].ToString();
          //  Labelarea2.Text = dr1[49].ToString();
            //Label49.Text = dr1[21].ToString();
            //Label50.Text = dr1[15].ToString();
            //Label51.Text = dr1[1].ToString();
            //Label52.Text = dr1[9].ToString();
            //Label53.Text = dr1[50].ToString();
            //Label54.Text = dr1[57].ToString();
            dr1.Close();
        }
        //conn.Close();
        conn1.Close();
        SqlConnection conn2 = null;
        conn2 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        conn2.Open();
        SqlCommand cmd2 = new SqlCommand("select * from properties where p_id=(SELECT MAX(p_id)-1 FROM properties)", conn2);
        SqlDataReader dr2 = cmd2.ExecuteReader();
        if (dr2.Read())
        {

            Label13.Text = dr2[21].ToString();
            Label14.Text = dr2[15].ToString();
            Label15.Text = dr2[1].ToString();
          //  Label16.Text = dr2[9].ToString();
           // Label17.Text = dr2[50].ToString();
            Label18.Text = dr2[57].ToString();
            Label63.Text = dr2[37].ToString();
            Label40.Text = dr2[15].ToString();
            Label41.Text = dr2[10].ToString();
            Label42.Text = dr2[21].ToString();
           // Labelarea3.Text = dr2[49].ToString();

           
            dr2.Close();
        }
        conn2.Close();
        SqlConnection conn3 = null;
        conn3 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        conn3.Open();
        SqlCommand cmd3 = new SqlCommand("select * from properties where p_id=(SELECT MAX(p_id)-2 FROM properties)", conn3);
        SqlDataReader dr3 = cmd3.ExecuteReader();
        if (dr3.Read())
        {

            Label19.Text = dr3[21].ToString();
            Label20.Text = dr3[15].ToString();
            Label21.Text = dr3[1].ToString();
            //Label22.Text = dr3[9].ToString();
          //  Label23.Text = dr3[50].ToString();
            Label24.Text = dr3[57].ToString();
            Label64.Text = dr3[37].ToString();
            Label43.Text = dr3[15].ToString();
            Label44.Text = dr3[10].ToString();
            Label45.Text = dr3[21].ToString();
          //  Labelarea4.Text = dr3[49].ToString();
           
            dr3.Close();
        }
        conn3.Close();
        SqlConnection conn4 = null;
        conn4 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        conn4.Open();
        SqlCommand cmd4 = new SqlCommand("select * from properties where p_id=(SELECT MAX(p_id)-3 FROM properties) ", conn4);
        SqlDataReader dr4 = cmd4.ExecuteReader();
        if (dr4.Read())
        {

            Label25.Text = dr4[21].ToString();
            Label26.Text = dr4[15].ToString();
            Label27.Text = dr4[1].ToString();
            Label28.Text = dr4[9].ToString();
           // Label29.Text = dr4[50].ToString();
            Label30.Text = dr4[57].ToString();
            Label65.Text = dr4[37].ToString();
         //   Labelarea5.Text = dr4[49].ToString();
            Label46.Text = dr4[15].ToString();
            Label47.Text = dr4[10].ToString();
            Label48.Text = dr4[21].ToString();
            dr4.Close();
        }
        conn4.Close();
        SqlConnection conn5 = null;
        conn5 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        conn5.Open();
        SqlCommand cmd5 = new SqlCommand("select * from properties where p_id=(SELECT MAX(p_id)-4 FROM properties) ", conn5);
        SqlDataReader dr5 = cmd5.ExecuteReader();
        if (dr5.Read())
        {

            Label31.Text = dr5[21].ToString();
            Label32.Text = dr5[15].ToString();
            Label33.Text = dr5[1].ToString();
          //  Label34.Text = dr5[9].ToString();
          //  Label35.Text = dr5[50].ToString();
          //  Labelarea6.Text = dr5[49].ToString();
            Label36.Text = dr5[57].ToString();
            Label66.Text = dr5[37].ToString();
            dr5.Close();
        }
        conn5.Close();

        SqlConnection conn6 = null;
        conn6 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        conn6.Open();
        SqlCommand cmd6 = new SqlCommand("select * from properties where p_id=(SELECT MIN(p_id)+1 FROM properties)  ", conn6);
        SqlDataReader dr6 = cmd6.ExecuteReader();
        if (dr6.Read())
        {

            Label55.Text = dr6[21].ToString();
            Label56.Text = dr6[15].ToString();
            Label57.Text = dr6[9].ToString();
            Label58.Text = dr6[50].ToString();
            Label59.Text = dr6[57].ToString();
            Label70.Text = dr6[37].ToString();
            Labelarea8.Text = dr6[49].ToString();
            dr6.Close();
        }
        conn6.Close();
        SqlConnection conn7 = null;
        conn7 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        conn7.Open();
        SqlCommand cmd7 = new SqlCommand("select *  from properties where p_id=(SELECT MIN(p_id)+2 FROM properties)  ", conn7);
        SqlDataReader dr7 = cmd7.ExecuteReader();
        if (dr7.Read())
        {

            Label71.Text = dr7[21].ToString();
            Label72.Text = dr7[15].ToString();
            Label73.Text = dr7[9].ToString();
            Label74.Text = dr7[50].ToString();
            Label75.Text = dr7[57].ToString();
            Label76.Text = dr7[7].ToString();
            Labelarea9.Text = dr7[49].ToString();
            dr7.Close();
        }
        conn7.Close();
        SqlConnection conn8 = null;
        conn8 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        conn8.Open();
        SqlCommand cmd8 = new SqlCommand("select *  from properties where p_id=(SELECT MIN(p_id)+3 FROM properties) ", conn8);
        SqlDataReader dr8 = cmd8.ExecuteReader();
        if (dr8.Read())
        {

            Label77.Text = dr8[21].ToString();
            Label78.Text = dr8[15].ToString();
            Label79.Text = dr8[9].ToString();
            Label80.Text = dr8[50].ToString();
            Label80.Text = dr8[57].ToString();
            Label82.Text = dr8[37].ToString();
            Labelarea10.Text = dr8[49].ToString();
            dr8.Close();
        }
        conn8.Close();
         SqlConnection conn9 = null;
        conn9 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        conn9.Open();
        SqlCommand cmd9 = new SqlCommand("select *  from properties where p_id=(SELECT MIN(p_id)+4 FROM properties) ", conn9);
        SqlDataReader dr9 = cmd9.ExecuteReader();
        if (dr9.Read())
        {

            Label83.Text = dr9[21].ToString();
            Label84.Text = dr9[15].ToString();
            Label85.Text = dr9[9].ToString();
            Label86.Text = dr9[50].ToString();
            Label87.Text = dr9[57].ToString();
            Label88.Text = dr9[37].ToString();
            Labelarea11.Text = dr9[49].ToString();
            dr9.Close();
        }
        conn9.Close();
        SqlConnection conn10 = null;
        conn10 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        conn10.Open();
        SqlCommand cmd10 = new SqlCommand("select *  from properties where p_id=(SELECT MIN(p_id)+5 FROM properties) ", conn10);
        SqlDataReader dr10 = cmd10.ExecuteReader();
        if (dr10.Read())
        {

            Label89.Text = dr10[21].ToString();
            Label90.Text = dr10[15].ToString();
            Label91.Text = dr10[9].ToString();
            Label92.Text = dr10[50].ToString();
            Label93.Text = dr10[57].ToString();
            Label94.Text = dr10[37].ToString();
            Labelarea12.Text = dr10[49].ToString();

            dr10.Close();
        }
        conn10.Close();
        SqlConnection conn12 = null;
        conn12 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        conn12.Open();
        SqlCommand cmd12 = new SqlCommand("select *  from properties where p_id=(SELECT MIN(p_id)+7 FROM properties) ", conn12);
        SqlDataReader dr12 = cmd12.ExecuteReader();
        if (dr12.Read())
        {

            Label101.Text = dr12[21].ToString();
            Label102.Text = dr12[15].ToString();
            Label103.Text = dr12[9].ToString();
            Label104.Text = dr12[50].ToString();
            Label105.Text = dr12[57].ToString();
            Label106.Text = dr12[37].ToString();
            Labelarea14.Text = dr12[49].ToString();
            dr12.Close();
        }
        conn12.Close();
        SqlConnection conn11 = null;
        conn11 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        conn11.Open();
        SqlCommand cmd11 = new SqlCommand("select *  from properties where p_id=(SELECT MIN(p_id)+6 FROM properties) ", conn11);
        SqlDataReader dr11 = cmd11.ExecuteReader();
        if (dr11.Read())
        {

            Label95.Text = dr11[21].ToString();
            Label96.Text = dr11[15].ToString();
            Label97.Text = dr11[9].ToString();
            Label98.Text = dr11[50].ToString();
            Label99.Text = dr11[57].ToString();
            Label100.Text = dr11[37].ToString();
            Labelarea13.Text = dr11[49].ToString();
            dr11.Close();
        }
        conn11.Close();
       
        SqlConnection conn13 = null;
        conn13 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        conn13.Open();
        SqlCommand cmd13 = new SqlCommand("select *  from properties where p_id=(SELECT MIN(p_id)+8 FROM properties) ", conn13);
        SqlDataReader dr13 = cmd13.ExecuteReader();
        if (dr13.Read())
        {

            Label107.Text = dr13[21].ToString();
            Label108.Text = dr13[15].ToString();
            Label109.Text = dr13[9].ToString();
            Label110.Text = dr13[50].ToString();
            Label111.Text = dr13[57].ToString();
            Label112.Text = dr13[37].ToString();
            Labelarea15.Text = dr13[49].ToString();
            dr13.Close();
        }
        conn13.Close();
        SqlConnection conn14 = null;
        conn14 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        conn14.Open();
        SqlCommand cmd14 = new SqlCommand("select *  from properties where p_id=(SELECT MIN(p_id)+9 FROM properties) ", conn14);
        SqlDataReader dr14 = cmd14.ExecuteReader();
        if (dr14.Read())
        {

            Label113.Text = dr14[21].ToString();
            Label114.Text = dr14[15].ToString();
            Label115.Text = dr14[9].ToString();
            Label116.Text = dr14[50].ToString();
            Label117.Text = dr14[57].ToString();
            Label118.Text = dr14[37].ToString();
            Labelarea16.Text = dr14[49].ToString();
            dr14.Close();
        }
        conn14.Close();
        SqlConnection conn15= null;
        conn15 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        conn15.Open();
        SqlCommand cmd15 = new SqlCommand("select * from agent_add where a_id=(SELECT MAX(a_id) FROM agent_add)  ", conn15);
        SqlDataReader dr15 = cmd15.ExecuteReader();
        if (dr15.Read())
        {

            Label119.Text = dr15[2].ToString();
            Label125.Text = dr15[15].ToString();
            Label121.Text = dr15[13].ToString();
        

            dr15.Close();
        }
        conn15.Close();
          SqlConnection conn16= null;
        conn16 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        conn16.Open();
        SqlCommand cmd16 = new SqlCommand("select * from agent_add where ID = (SELECT MAX(id)-1 FROM agent_add)   ", conn16);
        SqlDataReader dr16 = cmd16.ExecuteReader();
        if (dr16.Read())
        {

            Label122.Text = dr16[2].ToString();
            Label123.Text = dr16[15].ToString();
            Label124.Text = dr16[13].ToString();
        

            dr16.Close();
        }
        conn16.Close();
    }
    
}